import request from '@/utils/request'

// 查询柜组列表
export function listGroup(query) {
  return request({
    url: '/pos/group/list',
    method: 'get',
    params: query
  })
}

// 查询柜组详细
export function getGroup(groupId) {
  return request({
    url: '/pos/group/' + groupId,
    method: 'get'
  })
}

// 新增柜组
export function addGroup(data) {
  return request({
    url: '/pos/group',
    method: 'post',
    data: data
  })
}

// 修改柜组
export function updateGroup(data) {
  return request({
    url: '/pos/group',
    method: 'put',
    data: data
  })
}

// 删除柜组
export function delGroup(groupId) {
  return request({
    url: '/pos/group/' + groupId,
    method: 'delete'
  })
}

// 构建柜组树
export function buildGroupTree() {
  return request({
    url: '/pos/group/tree',
    method: 'get'
  })
}

// 查询柜组下拉树结构
export function treeselect() {
  return request({
    url: '/pos/group/treeselect',
    method: 'get'
  })
}

// 根据角色ID查询柜组树结构
export function roleGroupTreeselect(roleId) {
  return request({
    url: '/pos/group/roleGroupTreeselect/' + roleId,
    method: 'get'
  })
}

// 导出柜组列表
export function exportGroup(query) {
  return request({
    url: '/pos/group/export',
    method: 'post',
    data: query
  })
}

// 获取柜组关联的POS设备
export function getGroupDevices(groupId) {
  return request({
    url: '/pos/group/devices/' + groupId,
    method: 'get'
  })
}

// 获取柜组关联的收银员
export function getGroupCashiers(groupId) {
  return request({
    url: '/pos/group/cashiers/' + groupId,
    method: 'get'
  })
}

// 设置柜组关联的POS设备
export function setGroupDevices(groupId, deviceIds, operation = 'assign') {
  return request({
    url: '/pos/group/devices/' + groupId,
    method: 'post',
    data: {
      deviceIds: deviceIds,
      operation: operation
    }
  })
}

// 设置柜组关联的收银员
export function setGroupCashiers(groupId, cashierIds, operation = 'assign') {
  return request({
    url: '/pos/group/cashiers/' + groupId,
    method: 'post',
    data: {
      cashierIds: cashierIds,
      operation: operation
    }
  })
}
